import java.util.ArrayList;
import java.util.List;

/**
 * 1844. 将所有数字用字符替换
 * https://leetcode-cn.com/problems/replace-all-digits-with-characters/
 */
public class Solutions_1844 {
    public static void main(String[] args) {
        String s1 = "a1c1e1";  // output: "abcdef"
        String s2 = "a1b2c3d4e";  // output: "abbdcfdhe"
        String s3 = "v0g6s4d";  // output: "vvgmswd"

        List<String> inputs = new ArrayList<>();
        inputs.add(s1);
        inputs.add(s2);
        inputs.add(s3);

        for (String input : inputs) {
            String result = replaceDigits(input);
            System.out.println(result);
        }
    }

    public static String replaceDigits(String s) {
        char[] arr = s.toCharArray();
        for (int i = 1; i < arr.length; i += 2) {
            // 前一字母后移 arr[i] 位
            int asc = arr[i - 1] + (arr[i] - '0');
            arr[i] = (char) (asc);
        }
        return String.valueOf(arr);
    }
}
